<?php
namespace app\home\controller;
use app\home\model\AdModel;
use app\home\model\ArticleModel;
use app\home\model\CommentModel;
use app\home\model\IndexModel;
use think\Db;

class News extends Base
{

    /**
     * index [ 新闻详情页 ]
     * @author [Boot.Z] [852952656@qq.com]
     * @return mixed
     */
    public function index(){
        // +----------------------------------------------------------------------
        // |  新闻查询  START
        // +----------------------------------------------------------------------
        $id = input('param.id');
        $OneArticle = new ArticleModel();
        $article = $OneArticle -> getOneNews($id);
        $this->assign('article',$article);
        $this->assign('id',$id);
        //dump($article);die;
        // +----------------------------------------------------------------------
        // |  下一页新闻查询   START
        // +----------------------------------------------------------------------
        $After=$OneArticle->NextArticle($id);
        $this->assign('After',$After);

        // +----------------------------------------------------------------------
        // |  相关新闻查询   START
        // +----------------------------------------------------------------------
        $SuiJiNews = $OneArticle ->fetchSuiJiNews();
        $this->assign('SuiJiNews',$SuiJiNews);

        // +----------------------------------------------------------------------
        // |  评论内容   START
        // +----------------------------------------------------------------------
        $CommentModel = New CommentModel();
        $comment = $CommentModel -> fetchAllComment($id);
        $page = $comment -> render();
        $this->assign('comment',$comment);
        $this->assign('page',$page);


        $commentCount = $CommentModel -> getCommentCount($id);
       // dump($comment);die;
        $this -> assign('commentCount',$commentCount);

        return $this->fetch();
    }

    public function notice()
    {
        // +----------------------------------------------------------------------
        // |  相关政策法规查询根据ID   START
        // +----------------------------------------------------------------------
        $id = input('param.id');
        $pid = 20;
        $ArticleModel = new ArticleModel();
        $polies = $ArticleModel->getIdWherePilise($id,$pid);
        $this->assign('polies',$polies);

        // +----------------------------------------------------------------------
        // |  相关政策法规Title   START
        // +----------------------------------------------------------------------
        $Title = $ArticleModel ->getAllPoliseTitleAndId($pid);
        $this->assign('Title',$Title);

        return $this->fetch();
    }

    public function convention()
    {
        // +----------------------------------------------------------------------
        // |  相关政策法规查询根据ID   START
        // +----------------------------------------------------------------------
        $id = input('param.id');
        $pid = 26;
        $ArticleModel = new ArticleModel();
        $polies = $ArticleModel->getIdWherePilise($id,$pid);
        $this->assign('polies',$polies);

        // +----------------------------------------------------------------------
        // |  相关政策法规Title   START
        // +----------------------------------------------------------------------
        $Title = $ArticleModel ->getAllPoliseTitleAndId($pid);
        $this->assign('Title',$Title);

        return $this->fetch();
    }

    
    /**
     * hot_news [ 新闻热点页面 ]
     * @author [Boot.Z] [852952656@qq.com]
     */
    public function hot_news()
    {
       
        $ArticleModel = new ArticleModel();
        $hot_news = $ArticleModel->findAllTenTuiJianNews();
        $this->assign('hot_news',$hot_news);

        // +----------------------------------------------------------------------
        // |  相关政策法规Title   START
        // +----------------------------------------------------------------------
        $polies = $ArticleModel ->getOneNewTuiJianNews();
        $this->assign('polies',$polies);

        return $this->fetch();
    }

    /**
     * listing [ 新闻详情页]
     * @author [Boot.Z] [852952656@qq.com]
     */
    public function listing()
    {

        // +----------------------------------------------------------------------
        // |  商务合作 广告位   START
        // +----------------------------------------------------------------------
        $AdModel = New AdModel();
        $ShangWu = $AdModel ->ShangWu();
        $this->assign('ShangWu',$ShangWu);
        // +----------------------------------------------------------------------
        // |  文化咨询下方 广告位   START
        // +----------------------------------------------------------------------
        $WenHua = $AdModel ->WenHua();
        $this->assign('WenHua',$WenHua);
        // +----------------------------------------------------------------------
        // |  右侧热门 广告位   START
        // +----------------------------------------------------------------------
        $ReMen = $AdModel ->ReMen();
        $this->assign('ReMen',$ReMen);
        // +----------------------------------------------------------------------
        // |  影视大图 广告位   START
        // +----------------------------------------------------------------------
        $YingDa = $AdModel ->YingDa();
        $this->assign('YingDa',$YingDa);
        // +----------------------------------------------------------------------
        // |  影视小图 广告位   START
        // +----------------------------------------------------------------------
        $YingXiao = $AdModel ->YingXiao();
        $this->assign('YingXiao',$YingXiao);

        return $this->fetch();
    }

    /**
     * AllNews [ 全部新闻.综合新闻 ]
     * @author [Boot.Z] [852952656@qq.com]
     */
    public function allnews()
    {
        // +----------------------------------------------------------------------
        // |  综合新闻   START
        // +----------------------------------------------------------------------
        $id = [18,19,21,24,25];
        $ArticleModel = new ArticleModel();
        $list = $ArticleModel->fetchCateIDNewsAll($id);
        $page = $list->render();
        $this->assign('list',$list);
        $this->assign('page',$page);
        return $this->fetch();
    }

    /**
     * Nei [ 国内新闻]
     * @author [Boot.Z] [852952656@qq.com]
     */
    public function nei()
    {
        // +----------------------------------------------------------------------
        // |  国内新闻   START
        // +----------------------------------------------------------------------
        $id = [25];
        $ArticleModel = new ArticleModel();
        $list = $ArticleModel->fetchCateIDNewsAll($id);
        $page = $list->render();
        $this->assign('list',$list);
        $this->assign('page',$page);
        return $this->fetch();
    }

    /**
     * Wai [ 国外新闻 ]
     * @author [Boot.Z] [852952656@qq.com]
     * @return mixed
     */
    public function wai()
    {
        // +----------------------------------------------------------------------
        // |  国外新闻   START
        // +----------------------------------------------------------------------
        $id = [24];
        $ArticleModel = new ArticleModel();
        $list = $ArticleModel->fetchCateIDNewsAll($id);
        $page = $list->render();
        $this->assign('list',$list);
        $this->assign('page',$page);
        return $this->fetch();
    }


    /**
     * Mei [ 媒体新闻 ]
     * @author [Boot.Z] [852952656@qq.com]
     * @return mixed
     */
    public function mei()
    {
        // +----------------------------------------------------------------------
        // |  媒体新闻   START
        // +----------------------------------------------------------------------
        $id = [19];
        $ArticleModel = new ArticleModel();
        $list = $ArticleModel->fetchCateIDNewsAll($id);
        $page = $list->render();
        $this->assign('list',$list);
        $this->assign('page',$page);
        return $this->fetch();
    }




}
